//
//  headerView.m
//  ProductB
//
//  Created by lanou on 16/6/2.
//  Copyright © 2016年 ChenZheng. All rights reserved.
//

#import "headerView.h"

@implementation headerView


-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //背景图片
        self.bgImageView = [[UIImageView alloc]initWithFrame:self.bounds];
        _bgImageView.image = [UIImage imageNamed:@"2.jpg"];
        //图片不失真
        _bgImageView.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:_bgImageView];
        //添加毛玻璃
        UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
        
        UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
        
        effectview.frame = self.bounds;
        
        [_bgImageView addSubview:effectview];
        //头像
        self.headerView = [[UIImageView alloc]initWithFrame:CGRectMake((kWidth - 80)/2, (self.frame.size.height - 80)/2, 80, 80)];
        _headerView.backgroundColor = [UIColor cyanColor];
        _headerView.image = [UIImage imageNamed:@"header"];
        _headerView.layer.cornerRadius = 40;
        _headerView.layer.masksToBounds = YES;
        [effectview addSubview:_headerView];
        
        //用户名
        self.userLab = [[UILabel alloc]initWithFrame:CGRectMake((kWidth - 100)/2,(self.frame.size.height - 80)/2 + 80 , 90, 30)];
//        _userLab.backgroundColor = [UIColor greenColor];
        _userLab.textColor = [UIColor whiteColor];
        _userLab.text = @"哈哈";
        _userLab.textAlignment = NSTextAlignmentCenter;
        [effectview addSubview:_userLab];
        
        //关注和粉丝
        self.noteAndFansLab = [[UILabel alloc]initWithFrame:CGRectMake((kWidth - 150)/2, (self.frame.size.height - 80)/2 + 110, 150, 30)];
//        _noteAndFansLab.backgroundColor = [UIColor orangeColor];
        _noteAndFansLab.textColor = [UIColor whiteColor];
        _noteAndFansLab.text = @"0关注  |  0粉丝";
        _noteAndFansLab.textAlignment = NSTextAlignmentCenter;
        [effectview addSubview:_noteAndFansLab];
        //消息中心
        self.messageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//        self.messageBtn.backgroundColor = [UIColor grayColor];
        _messageBtn.frame = CGRectMake(kWidth - 60, 15, 40, 28);
        [self.messageBtn setImage:[UIImage imageNamed:@"message"] forState:UIControlStateNormal];
        [effectview addSubview:_messageBtn];
        
        //性别
        self.genderImageView = [[UIImageView alloc]initWithFrame:CGRectMake((kWidth - 100)/2 + 90, (self.frame.size.height - 80)/2 + 80 , 30, 30)];
//        _genderImageView.backgroundColor = [UIColor blueColor];
        _genderImageView.image = [UIImage imageNamed:@"man"];
        _genderImageView.layer.cornerRadius = 15;
        _genderImageView.layer.masksToBounds = YES;
        [effectview addSubview:_genderImageView];
    }
    return self;
}


@end
